/* eslint-disable react/prop-types */
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as actions from '../actions/index';
import { Router } from 'utils/router';
import { ConfigProvider } from '@teamix/ui';
import Home from './home';
import Settings from '../pages/settings';
import Callback from '../pages/callback';

class OrgRoot extends Component {
  render() {
    return (
      <ConfigProvider prefix="yx-">
        <Router basepath="/" primary={false}>
          <Callback path="/oauth/aliyun/success" />
          <Settings path="/settings/:page" />
          <Home
            default
            newbieTaskExpandStatus={this.props.root.newbieTaskExpandStatus}
            newbieTaskFinishedStatus={this.props.root.newbieTaskFinishedStatus}
            newbieTaskStatus={this.props.root.newbieTaskStatus}
            welcomeDialogStatus={this.props.organization?.projects?.welcomeDialogStatus}
          />
        </Router>
      </ConfigProvider>
    );
  }
}

export default connect(
  (state) => state,
  (dispatch) => bindActionCreators(actions, dispatch),
)(OrgRoot);
